package com.chexiang360.common.interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截配置--调用链
 * 创建者  科帮网 
 * 创建时间  2017年11月24日
 */
//@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {

	@Value("${config.isDev}")
	private String isDev; //是否是开发调试
	
	@Autowired
	SysInterceptor SysInterceptor;
	
	public void addInterceptors(InterceptorRegistry registry) {
		String[] patterns = new String[] { "/login","/*.html","/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**"};
		System.out.println( isDev );
		if("1".equals(isDev)) {
			registry.addInterceptor(SysInterceptor)
		                         .addPathPatterns("/**")
		                         .excludePathPatterns(patterns);
		
		}else {
			registry.addInterceptor(SysInterceptor).addPathPatterns("/**");
		}
	}
}